﻿using System;
using System.Threading;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Hosting;

namespace Sunny.Hangfire
{
    public class HangfireBackgroundService:BackgroundService
    {
        private readonly IRecurringJobManager _recurringJobManager;

        public HangfireBackgroundService(IRecurringJobManager recurringJobManager)
        {
            _recurringJobManager = recurringJobManager;
        }
        protected override Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _recurringJobManager.AddOrUpdate<StatisticsUser>("用户注册统计",s=>s.Run(),"1 9 9 * * ? ",TimeZoneInfo.Local);
            return Task.CompletedTask;
        }
    }
}